package org.gjw.config;

import cn.hutool.aop.ProxyUtil;
import lombok.NoArgsConstructor;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

import javax.annotation.Resource;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author guojunwang
 * @date 2022-05-10 21:38
 */
@NoArgsConstructor
public class DynamicDataSource extends AbstractRoutingDataSource {


    @Resource
    private DataSourceHolder dataSourceHolder;


    /**
     * 主要用于获取当前使用的数据源的key
     * @return
     */
    @Override
    protected Object determineCurrentLookupKey() {
        return dataSourceHolder.getDataSourceKey();
    }




}
